package com.youngjun.user.controller.admin;

import com.youngjun.common.mybatis.page.PageInfo;
import com.youngjun.common.mybatis.page.PageParams;
import com.youngjun.common.mybatis.web.BaseController;
import com.youngjun.common.mybatis.web.Response;
import com.youngjun.user.api.admin.IInterfaceRestApi;
import com.youngjun.user.pojo.dto.InterfaceDTO;
import com.youngjun.user.pojo.dto.query.FunctionInterfaceQueryDTO;
import com.youngjun.user.pojo.dto.query.InterfaceQueryDTO;
import com.youngjun.user.pojo.vo.InterfaceVO;
import com.youngjun.user.service.InterfaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/interface")
public class InterfaceController implements IInterfaceRestApi,BaseController {

    @Autowired
    InterfaceService interfaceService;

    @Override
    public Response<PageInfo<InterfaceVO>> queryUnAssignedList(FunctionInterfaceQueryDTO dto) {
        PageParams pageParams = getPageParams(dto);
        List<InterfaceVO> data = interfaceService.queryUnAssignedList(dto,pageParams);
        return new Response<>(new PageInfo<>(data,pageParams));
    }

    @Override
    public Response<List<InterfaceVO>> queryAssignedList(FunctionInterfaceQueryDTO dto) {
        List<InterfaceVO> data = interfaceService.queryAssignedList(dto);
        return new Response<>(data);
    }

    @Override
    public Response<PageInfo<InterfaceVO>> queryList(InterfaceQueryDTO dto) {
        PageParams pageParams = getPageParams(dto);
        List<InterfaceVO> data = interfaceService.queryList(dto,pageParams);
        return new Response<>(new PageInfo<>(data,pageParams));
    }

    @Override
    public Response<InterfaceVO> create(InterfaceDTO dto) {
        InterfaceVO data = interfaceService.create(dto);
        return new Response<>(data);
    }

    @Override
    public Response<InterfaceVO> modify(InterfaceDTO dto) {
        InterfaceVO data = interfaceService.modify(dto);
        return new Response<>(data);
    }

    @Override
    public Response<Void> delete(Long id) {
        interfaceService.delete(id);
        return new Response<>();
    }

}